<template>
  <div class="main-container">
    <div class="main-header">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>版权声明管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="wrap">
      <div class="content">
        <div class="search-container">
          <el-form ref="form" :model="form" >
            <el-form-item label="声明内容部分">
              <el-input style='width:70%;' rows='7' type="textarea" v-model="form.content"></el-input>
            </el-form-item>
            <el-form-item label="联系方式部分">
              <el-input style='width:70%;' rows='7' type="textarea" v-model="form.contactInfo"  placeholder='请输入联系方式内容，例如"联系邮箱：*****@*****"'></el-input>
            </el-form-item>
            <el-form-item style='margin-left:9%;'>
              <el-button type="primary" @click="onSubmit">保存</el-button>
              <el-button @click="onReset">重置</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        content: "", //声明内容部分
        contactInfo: "" //联系方式部分
      }
    };
  },
  mounted() {
     this.loadData()
  },
  activated() {
     this.loadData()
  },
  methods: {
    loadData() { //获取声明内容
        this.loading = true
        // const params ={
        //   ...this.form,
        //   currentPage: this.currentPage,
        //   pageSize: this.pageSize,
        // }
        this.$api.statement.detail().then(res => {
          if(res.success){
            this.form = res.data
            console.log(this.form)
            this.loading = false
          }else {
            this.loading = false
          }
        }).catch(err => {
          this.loading = false
        })
      },
    onSubmit() {
        console.log(this.form)
      this.$refs["form"].validate(valid => {
        if (valid) {
          const params = {
            ...this.form
          };
          this.$api.statement.add(params).then(res => {
            if (res.success) {
              this.$message.success("保存成功");
            }
          });
        }
      });
    },
    onReset() {
      this.$refs.form.resetFields();
      this.form.content = '';
      this.form.contactInfo = '';
    },
  }
};
</script>

<style>
</style>
